
namespace SharpTalk.Client.WpfApplication.Services
{
    using ViewModels;
    using Views;

    /// <summary>
    /// 
    /// </summary>
    public static class DisplayMessageService
    {
        /// <summary>
        /// 
        /// </summary>
        /// <param name="title"></param>
        /// <param name="message"></param>
        /// <param name="isError"></param>
        public static void ShowMessage(string title, string message, bool isError)
        {
            ShowDialogMessage(null, title, message, isError, true, false);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="parent"></param>
        /// <param name="title"></param>
        /// <param name="message"></param>
        /// <param name="isError"></param>
        public static void ShowMessage(WindowBase parent, string title, string message, bool isError)
        {
            ShowDialogMessage(parent, title, message, isError, true, false);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="parent"></param>
        /// <param name="message"></param>
        /// <param name="isError"></param>
        public static void ShowMessage(WindowBase parent, string message, bool isError)
        {
            ShowDialogMessage(parent, isError ? Resources.Messages.label_error : Resources.Messages.label_infos, message, isError, true, false);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="parent"></param>
        /// <param name="message"></param>
        /// <param name="isError"></param>
        /// <param name="showCancel"></param>
        public static void ShowMessage(WindowBase parent, string message, bool isError, bool showCancel)
        {
            ShowDialogMessage(parent, isError ? Resources.Messages.label_error : Resources.Messages.label_infos, message, isError, true, showCancel, false);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="owner"></param>
        /// <param name="title"></param>
        /// <param name="message"></param>
        /// <param name="isError"></param>
        /// <param name="showOkCancel"></param>
        /// <param name="showYesNo"></param>
        /// <returns></returns>
        public static bool? ShowDialogMessage(WindowBase owner, string title, string message, bool isError, bool showOkCancel, bool showYesNo)
        {
            var vmdl = new DialogMessageViewModel(new DialogMessageView())
                           {
                               Title = title,
                               Message = message,
                               IsError = isError,
                               IsInfo = !isError,
                               ShowButtonOk = showOkCancel,
                               ShowButtonCancel = showOkCancel,
                               ShowButtonYes = showYesNo,
                               ShowButtonNo = showYesNo
                           };

            if(isError)
                System.Media.SystemSounds.Exclamation.Play();

            return vmdl.View.ShowDialog(owner);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="owner"></param>
        /// <param name="title"></param>
        /// <param name="message"></param>
        /// <param name="isError"></param>
        /// <param name="showOk"></param>
        /// <param name="showCancel"></param>
        /// <param name="showYesNo"></param>
        /// <returns></returns>
        public static bool? ShowDialogMessage(WindowBase owner, string title, string message, bool isError, bool showOk, bool showCancel, bool showYesNo)
        {
            var vmdl = new DialogMessageViewModel(new DialogMessageView())
            {
                Title = title,
                Message = message,
                IsError = isError,
                IsInfo = !isError,
                ShowButtonOk = showOk,
                ShowButtonCancel = showCancel,
                ShowButtonYes = showYesNo,
                ShowButtonNo = showYesNo
            };

            if (isError)
                System.Media.SystemSounds.Exclamation.Play();

            return vmdl.View.ShowDialog(owner);
        }
    }
}